package cn.wolfcode.wolf2w.controller;

import cn.wolfcode.wolf2w.domain.StrategyTheme;
import cn.wolfcode.wolf2w.query.StrategyThemeQueryObject;
import cn.wolfcode.wolf2w.service.IDestinationService;
import cn.wolfcode.wolf2w.service.IStrategyThemeService;
import cn.wolfcode.wolf2w.util.JsonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;


@RequestMapping("strategyTheme")
@Controller
public class StrategyThemeController {

    @Autowired
    private IStrategyThemeService strategyThemeService;

    @Autowired
    private IDestinationService destinationService;

    /**
     * 页面展示
     * @param model
     * @param qo
     * @return
     */
    @RequestMapping("/list")
    public String list(Model model,@ModelAttribute("qo") StrategyThemeQueryObject qo){
        //查询页面数据
        Page page = strategyThemeService.query(qo);
        //分享数据到页面
        model.addAttribute("page", page);

        return "strategyTheme/list";
    }


    /**
     * 新增或编辑
     * @param strategyTheme
     * @return
     */
    @RequestMapping("saveOrUpdate")
    @ResponseBody
    public Object saveOrUpdate(StrategyTheme strategyTheme){

        strategyThemeService.saveOrUpdate(strategyTheme);
        return JsonResult.success();
    }


    /**
     * 删除
     * @return
     */
    @RequestMapping("/delete")
    @ResponseBody
    public Object delete(String id){
        strategyThemeService.delete(id);
        return JsonResult.success();
    }

}
